package com.lh.io.bio;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

    public static void main(String[] args) {

        ServerSocket serverSocket = null;
        InputStream is = null;
        BufferedReader br = null;
        Socket socket = null;
        try {
            //1.注册端口
            serverSocket = new ServerSocket(8088);
            //2.开始在这里暂停等待接收客户端的连接,得到一个端到端的Socket管道
            socket = serverSocket.accept();
            //3.获取字节输入流
            is = socket.getInputStream();
            //4.转换为缓冲字符输入流
            br = new BufferedReader(new InputStreamReader(is));
            //5.读取数据
            String msg;
            while ((msg = br.readLine()) != null) {
                System.out.println(msg);
            }


        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
